package cn.zwx.learn.basic.groovy.register;


import cn.zwx.learn.basic.groovy.handler.GroovyHandler;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
 * @description 注册groovy脚本
 * @author zhangwenxue
 * @createTime 2021/4/13 18:30
 **/
public class GroovyRegister {

    private static volatile GroovyRegister INSTANCE = new GroovyRegister();

    private GroovyRegister() {
    }

    private Map<String, GroovyHandler> groovyClassMap = new ConcurrentHashMap<>();

    public void put(String name, GroovyHandler handler) {
        groovyClassMap.put(name, handler);
    }

    public GroovyHandler get(String name) {
        return groovyClassMap.get(name);
    }

    public void remove(String name) {
        groovyClassMap.remove(name);
    }


    public static GroovyRegister getInstance() {
        return INSTANCE;
    }
}
